/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view.GUI.collections;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Ben
 */
 public class TableListModel extends AbstractTableModel implements ICollectionTableModel{
    private List data;
    private String[] columnNames = {"Data"};

    public TableListModel(List data){
            this.data = data;
    }

    public void addRow(int row){
            data.add(row,"");
    }

    public void removeRow(int row){
            data.remove(row);
    }

    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.size();
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data.get(row);
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    public boolean isCellEditable(int row, int col) {
            return true;
    }

    public void setValueAt(Object value, int row, int col) {
        data.set(row, value);
        fireTableCellUpdated(row, col);
    }

    public String toString() {
        return data.toString();
    }


 }
